1. Field of the Invention
The present invention relates to data communications, and more particularly to a method and system for integer-based encoding and integer-based decoding of bits by data encoders and data decoders, respectively.
2. Description of Related Art
Wireless networks and data networks transmit and receive massive amounts of data. As a result, the wireless networks and the data networks use encoders and decoders to reduce an amount of the data exchanged through the wireless networks and the data networks. The encoders and the decoders permit improved speed of transmission through the wireless networks and the data networks.
The encoders implement several types of encoding schemes to reduce the amount of data exchanged. For example, Huffman encoding can be used to reduce the amount of data exchanged. The Huffman encoding technique represents symbols (i.e., numbers or characters) contained in the data as variable length code words. The code words are assigned based on the probability of occurrence of the symbols. Short code words represent symbols that appear more frequently in the data while long code words represent symbols that appear less frequently in the data. A reduction in the data exchanged through the wireless networks and the data networks is achieved when short code words are used with a higher frequency to encode the data as compared to long code words.
Lempel-Ziv is another example of an encoding technique that encoders can use to reduce the amount of data exchanged. The Lempel-Ziv encoding technique involves representing, as a code word, repeating sequences of symbols contained in the data, rather than just repeating symbols. Frequently occurring repeating sequences of symbols are encoded as a short code word while infrequently repeating sequences of symbols are encoded as a long code word. Similarly, the reduction in the amount of data exchanged is achieved when short code words are used with a high frequency to replace frequently occurring repeating sequences of symbols.
The present invention stems from a realization that the existing encoding techniques rely on characteristics of the data being encoded. For example, the Huffman encoding technique and the Lempel-Ziv encoding technique depend on a high frequency of repeating symbols and a high frequency of repeating sequences of symbols, respectively, in the data being encoded to achieve compression. Additionally, the existing encoding techniques use a large amount of memory. The large amount of memory stores a mapping of the symbols or the sequences of symbols to the code words. Therefore, there exists a need for a method and system to be able to efficiently encode the data without the limitations and the requirements of existing encoding schemes.
In accordance with a principle aspect of the present invention, an encoder may store in memory a data array having a first integer value and a second integer value. The first integer value and the second integer value may, collectively, simulate a binary condition. For example, the first integer value may have a predefined characteristic, e.g., be odd, and the second integer value might not have the predefined characteristic, e.g., not be odd, and instead be even. The encoder may encode a single bit as the first integer value or the second integer value. For example, if the single bit is a zero, then the encoder may encode the single bit as the even integer value of the data array. On the other hand, if the single bit is a one, then the encoder may encode the single bit as the odd integer value of the data array.
Additionally, the encoder may have at least one register for keeping track of a number of bits equal to one that was encoded and a number of bits equal to zero that was encoded. If a zero bit is encoded, then the integer value of a first register may be adjusted, e.g., increased or decreased. Alternatively, if a one bit is encoded, then the integer value of a second register may be adjusted, e.g., increased or decreased.
Still additionally, the encoder may have registers for storing integer values with predetermined properties. The predetermined properties may be that the integer values are either a multiple of an integer factor F or the multiple of the integer factor F plus the integer factor F minus one. The integer factor, F, may be a predefined number selected for purposes of the encoding. The integer values in the registers may be adjusted as one or more bits in the block of bits are encoded while maintaining the predetermined properties.
The encoder may encode a block of bits to produce a compressed data block. The compressed data block may include at least one integer value. The at least one integer value may be defined by the registers that store the integer values with the predetermined properties.
A decoder may decode the at least one integer value in the compressed data block to recover the block of bits. The decoder may also have at least one register. The decoder may set the at least one register to the at least one integer value in the compressed data block.
The decoder may generate a first integer value or a second integer value from the at least one integer value in the at least one register. Similar to the encoder, the first integer value may have a predefined characteristic, e.g., odd, and the second integer might not have the predefined characteristic, e.g., not odd, and instead even.
If the decoder generates the first integer value, e.g., an odd number, then the decoder may decode a one bit from the compressed data block. Alternatively, if the decoder generates the second integer value, e.g., an even number, then the decoder may decode a zero bit from the compressed data block. Additionally, the decoder may adjust integer values in the at least one register to maintain the predetermined properties during the encoding of the block of bits as one or more bits in the compressed data block is decoded.